/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gfs.location;

import java.awt.Point;

/**
 * This class is truely just to build upon the methods already created in the class
 * Point. Is more specialized methods that maybe needed for specific purposes 
 * such as the @link Coordinate#getMirroredCoordinate method that only needs to be
 * used in special occasions.
 * 
 * @author Joel Jauregui
 */
public class Coordinate extends Point implements Cloneable
    {
    
    /**
     * The xC value of this coordinate
     */
    protected int xC;
    
    /**
     * The yC value of this coordinate
     */
    protected int yC;
    
    /**
     * Constructs a <tt>Coordinate</tt> with given xC and yC coordinates
     * 
     * @param xC
     *      The xC coordinate of this coordinate
     * @param yC
     *      The yC coordinate of this coordinate
     */
    public Coordinate(int xC, int yC)
        {
        super();
        this.xC = xC;
        this.yC = yC;
        }
    
    /**
     * Constructs a default <tt>Coordinate</tt> with its location at (0,0)
     */
    public Coordinate()
        {
        this(0,0);
        }        
    
    /**
     * Returns a new <tt>Coordinate</tt> that is this <tt>Coordinate</tt> mirrored
     * across the xC and yC axis
     * 
     * @return
     *      The mirrored <tt>Coordinate</tt> of this one
     */
    public Coordinate getMirroredCoordinate()
        {
        return new Coordinate(getXC() * -1, getYC() * -1);
        }

    /**
     * Creates a string that describes this <tt>Coordinate</tt>
     * 
     * @return
     *      A string with the xC and yC values of this <tt>Coordinate</tt> in the
     * format (xC,yC)
     */
    @Override
    public String toString() 
        {
        return getClass().getSimpleName() + " (" + xC + "," + yC + ")";
        }
        
    /**
     * Returns the xC value of this <tt>Coordinate</tt>
     * 
     * @return
     *      The xC value of this <tt>Coordinate</tt>
     */
    public int getXC() 
        {
        return xC;
        }

    /**
     * Returns the yC value of this <tt>Coordinate</tt>
     * 
     * @return
     *      The yC value of this <tt>Coordinate</tt>
     */   
    public int getYC() 
        {
        return yC;
        }

    /**
     * Tests whether this <tt>Coordinate</tt> is equal to another
     * <tt>Coordinate</tt>
     * 
     * @param obj
     *      The <tt>Coordinate</tt> to compare this one to
     * @return
     *      <tt>true</tt> if their xC and yC values are equal, otherwise 
     * <tt>false</tt>
     */
    @Override
    public boolean equals(Object obj) 
        {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Coordinate other = (Coordinate) obj;
        if (this.xC != other.xC) {
            return false;
        }
        if (this.yC != other.yC) {
            return false;
        }
        return true;
        }

    /**
     * Returns a clone of this <tt>Coordinate</tt>
     * 
     * @return
     *      A clone of this <tt>Coordinate</tt>
     */
    @Override
    public Object clone()
        {
        return super.clone();
        }
    
    /**
     * Returns a hash code value that is distinct to this object and is equal
     * to another Coordinate object with the same x and y values.
     * 
     * @return
     *      A hash code value that is distinct to this object
     */
    @Override
    public int hashCode() 
        {
        int hash = 3;
        hash = 37 * hash + this.xC;
        hash = 37 * hash + this.yC;
        return hash;
        }
    
    }
